Skip to content

Conversation

@scotthart
Copy link
Member

This PR modifies the generator produce C++ samples for overriding the universe domain, as well as, emitting dox files that incorporate the samples to produce the desired documentation.

The first commit has all the hand written changes. The other commits are outputs of the generation process.

@scotthart scotthart requested review from a team as code owners October 23, 2025 17:56
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Oct 23, 2025
@gemini-code-assist
Copy link

Summary of Changes

Hello @scotthart, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly upgrades the code generator's capabilities by enabling it to automatically create C++ code samples and comprehensive Doxygen documentation for overriding the universe domain in generated client libraries. This enhancement ensures that users have clear, readily available guidance on how to configure their client applications for various Google Cloud environments, improving usability and consistency across libraries.

Highlights

  • Universe Domain Overrides: The code generator now produces C++ samples and Doxygen documentation files for overriding the universe domain in client libraries.
  • Automated Documentation Generation: The generation process has been enhanced to automatically incorporate these new universe domain override samples and their corresponding documentation into the library's Doxygen output.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist
Copy link

Summary of Changes

Hello @scotthart, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the client libraries by introducing new C++ samples and corresponding documentation for overriding the default universe domain. This change streamlines the process for developers to configure universe domains, improving clarity and ease of use when working with different Google Cloud environments. The updates involve modifications to the code generation logic and documentation scripts to ensure these samples are consistently generated and integrated across various services.

Highlights

  • New Universe Domain Samples: Introduced C++ code samples demonstrating how to override the default universe domain for various client libraries.
  • Automated Documentation Generation: Modified the documentation generation script to automatically create and inject Doxygen .dox files that incorporate these new universe domain samples.
  • Generator Updates: Updated the code generator to produce the necessary C++ sample functions for setting the universe domain.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist
Copy link

Summary of Changes

Hello @scotthart, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the code generator to automatically produce C++ samples demonstrating how to override the universe domain for various client libraries. This includes generating the necessary code snippets and integrating them into the Doxygen documentation, thereby improving the clarity and usability of this advanced configuration option for developers.

Highlights

  • Universe Domain Override Samples: The pull request introduces the capability to generate C++ code samples specifically for overriding the universe domain in client libraries.
  • Doxygen Documentation Generation: Alongside the code samples, corresponding Doxygen documentation files are now emitted, ensuring that the new universe domain override functionality is well-documented and integrated into the existing documentation.
  • Code Generation Process: The changes follow a structured approach where initial handwritten modifications are made, followed by automated generation of the remaining output files.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the generation of samples and documentation for overriding the universe domain. The changes to the generator scripts and templates look good. However, I found a critical issue in the sample generator that produces uncompilable code. The generated code for setting the universe domain is missing a variable declaration and uses a StatusOr object where an Options object is expected. My review includes a suggestion to fix this in the generator, which will correct all the generated sample files.

Comment on lines 112 to 116
ud_options = google::cloud::AddUniverseDomainOption(std::move(options));
if (!ud_options.ok()) throw std::move(ud_options).status();
auto ud_client = google::cloud::$product_namespace$::$client_class_name$(
google::cloud::$product_namespace$::Make$connection_class_name$(ud_options));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The generated code for SetClientUniverseDomain has a few issues that will prevent it from compiling and may cause warnings:

  1. The ud_options variable is used without being declared. It should be declared with auto.
  2. google::cloud::AddUniverseDomainOption returns a google::cloud::StatusOr<Options>. The Make...Connection function expects a google::cloud::Options object, but it's being passed the StatusOr object directly. The StatusOr object needs to be checked for an error and then dereferenced using the * operator.
  3. The check !ud_options.ok() is valid, but using !ud_options is more idiomatic for StatusOr objects.
  4. The ud_client variable is not used, which will result in a compiler warning. This can be suppressed by casting it to void.

Here is a corrected version of the generated code:

Suggested change
ud_options = google::cloud::AddUniverseDomainOption(std::move(options));
if (!ud_options.ok()) throw std::move(ud_options).status();
auto ud_client = google::cloud::$product_namespace$::$client_class_name$(
google::cloud::$product_namespace$::Make$connection_class_name$(ud_options));
auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options));
if (!ud_options) throw std::move(ud_options).status();
auto ud_client = google::cloud::$product_namespace$::$client_class_name$(
google::cloud::$product_namespace$::Make$connection_class_name$(*ud_options));
(void)ud_client;

diegomarquezp
diegomarquezp previously approved these changes Oct 23, 2025
Copy link
Collaborator

@diegomarquezp diegomarquezp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just one minor question.

// in the provided Options for the Universe Domain associated with the
// credentials and adds it to the set of Options.
// If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used.
ud_options = google::cloud::AddUniverseDomainOption(std::move(options));
Copy link
Collaborator

@diegomarquezp diegomarquezp Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is ud_options assumed to be present elsewhere in the generated samples? I'm asking cause I would expect a local declaration with auto.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got ahead of myself and though I had verified this sample as working code. I had not.

Yes, ud_options does need to be declared.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the capability to generate C++ samples and documentation for overriding the universe domain. The changes to the generator scripts and templates are mostly correct and follow existing patterns. However, I've found a critical issue in the sample generator that produces non-compiling code. The ud_options variable is used before being declared, and the StatusOr object is passed to a function expecting the contained Options value. My review includes a specific comment with a code suggestion to fix this. Once the generator is corrected, all the generated sample files should be fixed.

Comment on lines 112 to 116
ud_options = google::cloud::AddUniverseDomainOption(std::move(options));
if (!ud_options.ok()) throw std::move(ud_options).status();
auto ud_client = google::cloud::$product_namespace$::$client_class_name$(
google::cloud::$product_namespace$::Make$connection_class_name$(ud_options));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The generated code has a couple of issues that will prevent it from compiling:

  1. The ud_options variable is used without being declared. It should be declared with auto.
  2. The ud_options variable is a google::cloud::StatusOr<google::cloud::Options>, but the Make$connection_class_name$ function expects a google::cloud::Options object. You need to dereference ud_options (e.g., using *ud_options) to pass the contained value.
Suggested change
ud_options = google::cloud::AddUniverseDomainOption(std::move(options));
if (!ud_options.ok()) throw std::move(ud_options).status();
auto ud_client = google::cloud::$product_namespace$::$client_class_name$(
google::cloud::$product_namespace$::Make$connection_class_name$(ud_options));
auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options));
if (!ud_options.ok()) throw std::move(ud_options).status();
auto ud_client = google::cloud::$product_namespace$::$client_class_name$(
google::cloud::$product_namespace$::Make$connection_class_name$(*ud_options));

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds the capability to generate C++ samples and documentation for overriding the universe domain. The changes correctly modify the generator to produce the necessary sample code and Doxygen files. The implementation includes refactoring the sample generator for better modularity. However, there is a critical issue in the generated sample code where a variable is used without being declared, which will cause compilation failures. This needs to be addressed.

// in the provided Options for the Universe Domain associated with the
// credentials and adds it to the set of Options.
// If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used.
ud_options = google::cloud::AddUniverseDomainOption(std::move(options));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The variable ud_options is used without being declared. This will cause a compilation error in all generated sample files for this feature. It should be declared using auto to capture the StatusOr<Options> returned by AddUniverseDomainOption.

Suggested change
ud_options = google::cloud::AddUniverseDomainOption(std::move(options));
auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options));

@codecov
Copy link

codecov bot commented Oct 24, 2025

Codecov Report

❌ Patch coverage is 87.91209% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.10%. Comparing base (1cbff5a) to head (2aba6c9).

Files with missing lines Patch % Lines
generator/internal/scaffold_generator.cc 0.00% 6 Missing ⚠️
generator/internal/sample_generator.cc 85.71% 5 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main   #15654    +/-   ##
========================================
  Coverage   93.10%   93.10%            
========================================
  Files        2439     2439            
  Lines      223941   224070   +129     
========================================
+ Hits       208493   208615   +122     
- Misses      15448    15455     +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants